//
//  ImageViewController.m
//  CoreData
//
//  Created by ibokan on 14-11-6.
//  Copyright (c) 2014年 ibokan. All rights reserved.
//

#import "ImageViewController.h"

@interface ImageViewController ()

@end

@implementation ImageViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

- (IBAction)chooseImage:(UIButton *)sender {
    NSBundle *bundle = [NSBundle mainBundle];
    
    NSString *path = [bundle pathForResource:[NSString stringWithFormat:@"%@",sender.currentTitle] ofType:@"png"];
    
    NSMutableDictionary * dic = [[NSMutableDictionary alloc]initWithCapacity:2];
    [dic setValue:path forKey:@"path"];
    
    NSNotification * notification = [NSNotification notificationWithName:@"IMAGE" object:self userInfo:dic];
    [[NSNotificationCenter defaultCenter]postNotification:notification];
    
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)dealloc{
    [[NSNotificationCenter defaultCenter]removeObserver:self name:@"IMAGE" object:nil];
}















@end
